package atguigu.ScadaEquipCheckNodeInfoUtils;

import org.apache.commons.lang.StringUtils;

import com.alibaba.fastjson.JSONObject;

import cn.hutool.core.io.FileUtil;

public class CR2 {

	public static void main(String[] args) {
		
		String aCode = "A1502010002190021,油脂分离度测试装置,安徽中家智锐/YZFL-2;"+
				"A2301010002190001,国标风量测试装置,安徽中家智锐/FL1;"+
				"A2248000003190011,欧标空气性能风量测试装置,安徽中家智锐/F401-30;";
		
		String checkNode = 
				"1,15020100021094200001,a1质量;"+
				"2,15020100021094200002,b1质量;"+
				"3,15020100021094200003,c1质量;"+
				"4,15020100021094200004,a2质量;"+
				"5,15020100021094200005,b2质量;"+
				"6,15020100021094200006,c2质量;"+
				"7,15020100021094200007,Fz测试值;"+
				"8,15020100021094200008,Fw测试值;"+
				"9,15020100021094200009,Fz限值;"+
				"10,15020100021094200010,Fw限值;"+
				"11,15020100021094200011,Fz结论判定;"+
				"12,15020100021094200012,Fw结论判定;"+
				"13,15020100021094200013,委托单号;"+
				"14,15020100021094200014,测试项编号;"+
				"15,15020100021094200015,样品型号;"+
				"16,15020100021094200016,样品编号;"+
				"17,15020100021094200017,数据上传(标志);";
				
//		 private String equipmentName;// 设备名称
//		 private String aCode;// A码
//		 private String checkNodeId; // 监测点编码
//		 private String sampleModel; // 机型
//		 private String checkNodeType;// 测点类别
		
		String[] split = aCode.split(";");
		String[] split3 = checkNode.split(";");
		FileUtil.appendString("[", "D://ScadaEquipCheckNodeInfo2.txt", "UTF-8");
		for (int i = 0; i < split.length; i++) {
			if(StringUtils.isNotBlank(split[i])) {
				String[] split2 = split[i].trim().split(",");
				for (int j = 0; j < split3.length; j++) {
					ScadaEquipCheckNodeInfo info = new ScadaEquipCheckNodeInfo();
					info.setaCode(split2[0].trim());
					info.setEquipmentName(split2[1].trim());
					info.setSampleModel(split2[2].trim());
					info.setEquipmentNo(split2[0]);
					if (StringUtils.isNotBlank(split3[j])) {
						String[] split4 = split3[j].split(",");
						info.setWorkLocation(split4[0].trim());
						info.setCheckNodeId(split4[1].trim());
						info.setCheckNodeType(split4[2].trim());
						
						System.out.println(JSONObject.toJSONString(info) + ",");
						FileUtil.appendString(JSONObject.toJSONString(info) + ",", "D://ScadaEquipCheckNodeInfo2.txt", "UTF-8");
					}
				}
			}
		}
		FileUtil.appendString("]", "D://ScadaEquipCheckNodeInfo2.txt", "UTF-8");
		System.out.println("结束");
	}
}
